home *** CD-ROM | disk | FTP | other *** search
/ Echoes of Ireland / Echoes of Ireland.iso / IRISH_ENGINE / quiz / quiz.swf / scripts / frame_13 / DoAction.as
Encoding:
Text File  |  2004-06-16  |  1.2 KB  |  47 lines

  1. function buildQuestionsArray4()
  2. {
  3.    stripWhitespaceDoublePass(quizDoc4);
  4.    var quizNode = quizDoc4.firstChild;
  5.    var i = 0;
  6.    while(i < quizNode.childNodes.length)
  7.    {
  8.       var thisQuestion = quizNode.childNodes[i];
  9.       var choicesArray = new Array();
  10.       var j = 0;
  11.       while(j < thisQuestion.childNodes.length)
  12.       {
  13.          var thisChoice = thisQuestion.childNodes[j];
  14.          choicesArray[j] = thisChoice.firstChild.nodeValue;
  15.          j++;
  16.       }
  17.       questionsArray[i] = new Question(parseInt(thisQuestion.attributes.answer),thisQuestion.attributes.text,choicesArray);
  18.       i++;
  19.    }
  20.    questionsArray.shuffle();
  21.    loadMsg = "";
  22.    makeQuestion(currentQuestion);
  23. }
  24. function answer(choice)
  25. {
  26.    userAnswers.push(choice);
  27.    MeAnswer = userAnswers.length;
  28.    if(userAnswers[MeAnswer - 1] == questionsArray[currentQuestion].correctAnswer)
  29.    {
  30.       totalCorrect++;
  31.    }
  32.    if(currentQuestion + 1 == 5)
  33.    {
  34.       questionClip.removeMovieClip();
  35.       gotoAndStop("echoes");
  36.    }
  37.    else
  38.    {
  39.       makeQuestion(++currentQuestion);
  40.    }
  41. }
  42. stop();
  43. var currentQuestion = 0;
  44. var quizDoc4 = new XML();
  45. quizDoc4.onLoad = buildQuestionsArray4;
  46. quizDoc4.load("quiz/quiz4.xml");
  47.